<script>
export default {
  name: 'OfflineOrder',
  data() {
    return {
      orders: [
        { id: 'OF-2023-001', customer: '北京分店', date: '2023-10-01', status: '已处理', priority: '普通' },
        { id: 'OF-2023-002', customer: '上海分店', date: '2023-10-02', status: '处理中', priority: '普通' },
        { id: 'OF-2023-003', customer: '广州分店', date: '2023-10-03', status: '待处理', priority: '高' },
        { id: 'OF-2023-004', customer: '深圳分店', date: '2023-10-04', status: '已完成', priority: '普通' },
      ]
    };
  },
  methods: {
    goToHome() {
      this.$router.push('/home');
    },
    getStatusClass(status) {
      switch(status) {
        case '已处理': return 'status-processed';
        case '处理中': return 'status-processing';
        case '待处理': return 'status-pending';
        case '已完成': return 'status-completed';
        default: return '';
      }
    },
    getPriorityClass(priority) {
      switch(priority) {
        case '紧急': return 'priority-urgent';
        case '高': return 'priority-high';
        case '普通': return 'priority-normal';
        default: return '';
      }
    }
  }
}
</script>

<template>
  <div class="order-page">
    <div class="page-header">
      <button class="back-button" @click="goToHome">
        <span class="icon-arrow-left"></span>
        返回首页
      </button>
      <h1>线下订单管理</h1>
      <div class="header-actions">
        <button class="refresh-btn">
          <span class="icon-refresh"></span> 刷新
        </button>
        <button class="export-btn">
          <span class="icon-export"></span> 导出
        </button>
      </div>
    </div>
    
    <div class="page-content">
      <div class="filter-bar">
        <input type="text" placeholder="搜索订单号/分店名称" class="search-input">
        <select class="status-filter">
          <option value="">全部状态</option>
          <option value="待处理">待处理</option>
          <option value="处理中">处理中</option>
          <option value="已处理">已处理</option>
          <option value="已完成">已完成</option>
        </select>
        <button class="filter-btn">筛选</button>
      </div>
      
      <div class="order-stats">
        <div class="stat-card">
          <div class="stat-value">{{ orders.length }}</div>
          <div class="stat-label">总订单数</div>
        </div>
        <div class="stat-card">
          <div class="stat-value">{{ orders.filter(o => o.status === '待处理').length }}</div>
          <div class="stat-label">待处理</div>
        </div>
        <div class="stat-card">
          <div class="stat-value">{{ orders.filter(o => o.status === '处理中').length }}</div>
          <div class="stat-label">处理中</div>
        </div>
        <div class="stat-card">
          <div class="stat-value">{{ orders.filter(o => o.status === '已完成').length }}</div>
          <div class="stat-label">已完成</div>
        </div>
      </div>
      
      <div class="order-table-container">
        <table class="order-table">
          <thead>
            <tr>
              <th>订单编号</th>
              <th>分店名称</th>
              <th>提交日期</th>
              <th>优先级</th>
              <th>状态</th>
              <th>操作</th>
            </tr>
          </thead>
          <tbody>
            <tr v-for="order in orders" :key="order.id" class="order-row">
              <td>{{ order.id }}</td>
              <td>{{ order.customer }}</td>
              <td>{{ order.date }}</td>
              <td><span :class="['priority-tag', getPriorityClass(order.priority)]">{{ order.priority }}</span></td>
              <td><span :class="['status-tag', getStatusClass(order.status)]">{{ order.status }}</span></td>
              <td>
                <button class="view-btn">查看</button>
                <button class="edit-btn">处理</button>
              </td>
            </tr>
          </tbody>
        </table>
      </div>
      
      <div class="pagination">
        <button class="page-btn">上一页</button>
        <button class="page-num active">1</button>
        <button class="page-num">2</button>
        <button class="page-num">3</button>
        <button class="page-btn">下一页</button>
        <span class="page-info">共 18 条，每页 10 条</span>
      </div>
    </div>
  </div>
</template>

<style scoped>
/* 样式与EmailOrder.vue相同，略作颜色调整以区分不同订单类型 */
.order-page {
  padding: 20px;
  background-color: #f5f7fa;
  min-height: 100vh;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 1px solid #e1e5e8;
}

.back-button {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 15px;
  background: #e67e22;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.3s;
  font-weight: 500;
}

.back-button:hover {
  background: #d35400;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

h1 {
  color: #2c3e50;
  font-size: 22px;
  margin: 0;
}

.header-actions {
  display: flex;
  gap: 10px;
}

.refresh-btn, .export-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 8px 12px;
  background: white;
  border: 1px solid #ddd;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
  color: #555;
}

.refresh-btn:hover, .export-btn:hover {
  background-color: #f8f9fa;
  border-color: #ccc;
}

.page-content {
  background: white;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  padding: 20px;
}

.filter-bar {
  display: flex;
  gap: 15px;
  margin-bottom: 20px;
  align-items: center;
}

.search-input {
  flex: 1;
  padding: 10px 15px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
}

.status-filter {
  padding: 10px 15px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
  background-color: white;
}

.filter-btn {
  padding: 10px 20px;
  background-color: #e67e22;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.filter-btn:hover {
  background-color: #d35400;
}

.order-stats {
  display: flex;
  gap: 15px;
  margin-bottom: 25px;
}

.stat-card {
  flex: 1;
  background-color: #f8f9fa;
  padding: 15px;
  border-radius: 8px;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.stat-value {
  font-size: 24px;
  font-weight: bold;
  color: #e67e22;
  margin-bottom: 5px;
}

.stat-label {
  color: #7f8c8d;
  font-size: 14px;
}

.order-table-container {
  overflow-x: auto;
  margin-bottom: 20px;
}

.order-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 768px;
}

.order-table th, .order-table td {
  padding: 12px 15px;
  text-align: left;
  border-bottom: 1px solid #eee;
}

.order-table th {
  background-color: #f8f9fa;
  font-weight: 600;
  color: #555;
}

.order-row:hover {
  background-color: #f9f9f9;
}

.status-tag {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
}

.status-pending {
  background-color: #fff3cd;
  color: #856404;
}

.status-processing {
  background-color: #d1ecf1;
  color: #0c5460;
}

.status-processed {
  background-color: #d4edda;
  color: #155724;
}

.status-completed {
  background-color: #e8f4fd;
  color: #0066b2;
}

.priority-tag {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
}

.priority-urgent {
  background-color: #f8d7da;
  color: #721c24;
}

.priority-high {
  background-color: #ffeeba;
  color: #856404;
}

.priority-normal {
  background-color: #d1ecf1;
  color: #0c5460;
}

.view-btn, .edit-btn {
  padding: 5px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s;
  border: none;
  margin-right: 5px;
}

.view-btn {
  background-color: #e9ecef;
  color: #495057;
}

.view-btn:hover {
  background-color: #dee2e6;
}

.edit-btn {
  background-color: #e67e22;
  color: white;
}

.edit-btn:hover {
  background-color: #d35400;
}

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 20px;
}

.page-btn {
  padding: 6px 12px;
  border: 1px solid #ddd;
  background-color: white;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}

.page-btn:hover {
  background-color: #f8f9fa;
  border-color: #ccc;
}

.page-num {
  width: 30px;
  height: 30px;
  border: 1px solid #ddd;
  background-color: white;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.page-num.active {
  background-color: #e67e22;
  color: white;
  border-color: #e67e22;
}

.page-num:hover:not(.active) {
  background-color: #f8f9fa;
  border-color: #ccc;
}

.page-info {
  color: #666;
  font-size: 14px;
  margin-left: 10px;
}

/* 图标样式 */
.icon-arrow-left::before {
  content: "←";
}

.icon-refresh::before {
  content: "↺";
}

.icon-export::before {
  content: "↓";
}

/* 响应式调整 */
@media (max-width: 768px) {
  .order-stats {
    flex-direction: column;
  }
  
  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }
  
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 15px;
  }
  
  .header-actions {
    width: 100%;
    justify-content: flex-end;
  }
}
</style>